﻿using System;
using System.Windows;

namespace SilverlightClientLibrary.Utils
{
    public static class PointExtensions
    {
        public static byte[] EncodePoint(this Point p)
        {
            byte[] retBytes = new byte[4];

            retBytes[0] = (byte)(p.X / 256);
            retBytes[1] = (byte)(p.X % 256);
            retBytes[2] = (byte)(p.Y / 256);
            retBytes[3] = (byte)(p.Y % 256);

            return retBytes;
        }

        public static Point DecodePoint(this Point p, byte[] b)
        {
            p = new Point();

            p.X = b[0] * 256;
            p.X += b[1];
            p.Y = b[2] * 256;
            p.Y += b[3];

            return p;
        }
    }
}
